/*
 * Timer.h
 *
 *  Created on: 04.05.2011
 *      Author: Hugme
 */

#ifndef TIMER_H_
#define TIMER_H_
#define CODE_TIMER 1

#include <time.h>
#include <sys/siginfo.h>
#include <errno.h>
#include <sys/neutrino.h>
#include <stdio.h>
#include <stdlib.h>

class Timer {
public:
    Timer();
    void addTimer(int chid, int sec, int nsec, int intervallSec, int intervallNsec);
    struct itimerspec* getRemainingTime();
    void restartTimer();
    void abortTimer();
    void pauseTimer();
    void resumeTimer();
    timer_t getTimerID();
    int getTimerState();
private:
    timer_t timerID; // timer ID for timer
    struct sigevent event; // event to deliver
    struct itimerspec timer; // the timer data structure
    struct itimerspec remainingTime;
    struct itimerspec initialTime;
    int chid;
    int sec;
    int nsec;
    int intervallSec;
    int intervallNsec;
    int coid; // connection back to ourselves
    int state;
};

#endif /* TIMER_H_ */
